package base.tree.countLeaves;

import base.tree.TreeNode;

public class Solution {

    //统计叶子结点个数
    public static int NodeCount(TreeNode root) {
        if (root == null) {
            return 0;
        }
        return NodeCount2(root);

    }

    public static int NodeCount2(TreeNode node) {
        if (node.left == null && node.right == null) {
            return 1;
        }
        return NodeCount2(node.left) + NodeCount2(node.right);
    }
}
